feat(sql): add x402 and MPP payment lanes - #60
Draft
johnpmitsch wants to merge 2 commits into
Draft
Conversation
SQL Explorer can run without an account: clusters and schema stay public, and query pays with x402 drawdown or an MPP session. qn micropayments (alias pay) shares the existing x402 and mpp runners.
The MPP query path returned on error before saving the channel, so a query that failed after the gateway banked the voucher left the cached cumulative behind the gateway's accepted value. The next query re-signed that stale cumulative and was refused, stranding the channel. The SDK now advances the channel whenever the voucher reached the gateway, and this saves it on both paths before mapping the error. Also gates the credit and channel error matchers on a 402: the body markers were alternatives to the status check, so a 500 whose message happened to contain "insufficient" reported as an empty balance. Docs: SQL has no per-request --x402 flag, so context.md no longer claims it is rejected; the no-payer query is documented as exit 1, since a key is one of three ways to pay; drops an absence-of-feature line from the README MPP intro. Tests: a failed query persists the receipt cumulative, sql clusters maps a catalog error to exit 2, buy-credits clears the gate with --yes, and a clusters table snapshot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds SQL Explorer without a Quicknode account: wallet, fund, query. The account-key path stays.
qn sql clustersandqn sql schemaalways hit the public catalog. Onlyqn sql querychooses who pays: an API key,--x402-drawdown, or--mpp-session. Config never turns a payment path on.qn micropayments(aliaspay) is the shared funding noun.qn rpc x402andqn rpc mppstay first-class and call the same runners.Channel accounting on the MPP lane
The paid query saves the channel on both the success and error paths, before mapping the error:
The SDK advances
channelwhenever the voucher reached the gateway. Previously the CLI returned on error before saving, so a query that failed after the gateway banked the voucher left the cached cumulative behind the gateway's accepted value; the next query re-signed that stale value and was refused, stranding the channel.Error matching
Both payment matchers now gate on the status. The body markers were
||-alternatives to the 402 check, so a 500 whose message happened to contain"insufficient"reported as an empty balance:Docs
sql queryhas no per-request--x402/--mppflag; context.md no longer says the flag is "rejected" (clap emits a generic unknown-argument error).sql queryis documented as exit 1. A key is one of three ways to pay, so a missing payer is a usage error, notno API key found(exit 4, which stays the default for key-required commands).Dependency
Pinned to
quicknode/sdk@0bd4f3c(quicknode/sdk#60), git-pinned until that crate is published. A release cannot ship from a git rev.Closes DX-6602
Test plan
cargo test --test sql --test micropayments --test rpc_payment --test cli_smoke— 86 passedcargo test— 462 passedcargo clippy --all-targets -- -D warningscargo fmt --checkNew coverage: a failed MPP query persists the receipt cumulative;
sql clustersmaps a catalog error to exit 2;buy-creditsclears the confirmation gate with--yes; insta snapshot for thesql clusterstable.